package com.yf.controller.api.meetingUser;

import com.yf.annotation.IgnoreAuth;
import com.yf.entity.meetingUser.AuctionEntity;
import com.yf.response.R;
import com.yf.service.meetingUser.AuctionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;


/**
 * 拍卖Controller
 *
 * @author hxf
 * @email 505860922@qq.com
 * @date Fri Dec 14 15:54:30 CST 2018
 */
@RestController
@RequestMapping("/api/auction")
public class ApiAuctionController {
    @Autowired
    private AuctionService auctionService;

    @GetMapping("/list")
    @IgnoreAuth
    public R list() {
        return R.ok(auctionService.getByStatus(0).get(0));
    }

    @PostMapping("/save")
    @IgnoreAuth
    public R save(String name, BigDecimal money, String goods,Integer amount,String team) {
        AuctionEntity auctionEntity = new AuctionEntity(name,money,goods,amount,team,new Date());
        auctionService.saveAuction(auctionEntity);
        return R.ok();
    }

    @GetMapping("/delete")
    @IgnoreAuth
    public R delete(Long aId) {
        auctionService.deleteById(aId);
        return R.ok();
    }
}
